package com.freewater.javabase.demo.designpattern.command2.macro.client;

import com.freewater.javabase.demo.designpattern.command2.macro.command.*;
import com.freewater.javabase.demo.designpattern.command2.macro.invoker.RemoteControllerWithUndo;
import com.freewater.javabase.demo.designpattern.command2.macro.receiver.Garage;
import com.freewater.javabase.demo.designpattern.command2.macro.receiver.Light;

/**
* 客户端
* Created by FreeWater on 2017/4/4.
*/
public class RemoteControllerTest {
	public static void main(String[] args) {
		Light light = new Light("Living room");
		LightOnCommand lightOnCommand = new LightOnCommand(light);
		LightOffCommand lightOffCommand = new LightOffCommand(light);

		Garage garage = new Garage();
		GarageDoorUpCommand garageDoorUpCommand = new GarageDoorUpCommand(garage);
		GarageDoorDownCommand garageDoorDownCommand = new GarageDoorDownCommand(garage);

		Command[] onCommands = new Command[]{lightOnCommand, garageDoorUpCommand};
		Command[] offCommands = new Command[]{lightOffCommand, garageDoorDownCommand};
		MacroCommand onMacroCommand = new MacroCommand(onCommands);
		MacroCommand offMacroCommand = new MacroCommand(offCommands);

		RemoteControllerWithUndo remoteControllerWithUndo = new RemoteControllerWithUndo();
		remoteControllerWithUndo.setCommand(0, onMacroCommand, offMacroCommand);
		remoteControllerWithUndo.onButtonWasPressed(0);
		remoteControllerWithUndo.offButtonWasPressed(0);
		remoteControllerWithUndo.undoButtonWasPressed();
	}
}
